
#include <amxmodx>
#include <cstrike>
#include <csx>
#include <engine>
#include <pokemod>

enum POKEMOD_BADGE
{
	BADGE_NONE = -1,
	BADGE_BOULDER,
	BADGE_CASCADE,
}

new g_szBadges[ POKEMOD_BADGE ][] = {
	"Boulder Badge",
	"Cascade Badge"
}

#define CASCADE_DISTANCE 1000

new POKEMOD_BADGE:g_iBadgeAttempt[ 33 ];

public plugin_init()
{
	register_plugin( "PokeMod Gym Battles", "0.1", "Emp`" );
}

public plugin_cfg()
{
	PokeModRegisterFunction( "GymBattle" );
}

public PokeScriptGymBattle( iPlayer, szArg1[] )
{
	new POKEMOD_BADGE:iBadge = BADGE_NONE;
	for ( new POKEMOD_BADGE:iBadgeCheck; iBadgeCheck < POKEMOD_BADGE; iBadgeCheck++ )
	{
		if ( equali( g_szBadges[ iBadgeCheck ], szArg1 ) )
		{
			iBadge = iBadgeCheck;
			break;
		}
	}

	if ( iBadge == BADGE_NONE )
		return 0;

	g_iBadgeAttempt[ iPlayer ] = iBadge;
	switch ( iBadge )
	{
		case BADGE_BOULDER:
		{
			PokeModExecuteScript( iPlayer, "EventPrint( Get a Grenade Kill to earn the %s! )", g_szBadges[ iBadge ] );
		}
		case BADGE_CASCADE:
		{
			PokeModExecuteScript( iPlayer, "EventPrint( Get a Kill from a distance of %d to earn the %s! )", CASCADE_DISTANCE, g_szBadges[ iBadge ] );
		}
	}

	new szName[32];
	get_user_name( iPlayer, szName, charsmax(szName) );
	PokeModExecuteScript( iPlayer, "EventPrintAll( %s is trying to earn the %s! )", szName, g_szBadges[ iBadge ] );

	return 1;
}

public client_death( iKiller, iVictim, iWeapon, iHitPlace, iTK )
{
	if ( iTK )
		return;

	if ( cs_get_user_team( iKiller ) == cs_get_user_team( iVictim ) )
		return;

	new POKEMOD_BADGE:iBadge = g_iBadgeAttempt[ iKiller ];
	switch ( iBadge )
	{
		case BADGE_BOULDER:
		{
			if ( iWeapon == CSW_HEGRENADE )
			{
				new szName[ 32 ], szBadge[ 32 ];
				get_user_name( iKiller, szName, charsmax(szName) );
				copy( szBadge, charsmax(szBadge), g_szBadges[ iBadge ] );
				PokeModExecuteScript( iKiller, "GiveSpecial( %s )", szBadge );
				PokeModExecuteScript( iKiller, "EventPrintAll( %s has earned the %s! )", szName, szBadge );
				PokeModExecuteScript( iKiller, "GiveItem( TM 34 )" );
				PokeModExecuteScript( iKiller, "EventPrint( Brock: Good job. Here is the %s and TM 34. )", szBadge );
				g_iBadgeAttempt[ iKiller ] = BADGE_NONE;
			}
		}
		case BADGE_CASCADE:
		{
			new Float:fDist = entity_range( iKiller, iVictim )
			if ( fDist >= CASCADE_DISTANCE )
			{
				new szName[ 32 ], szBadge[ 32 ];
				get_user_name( iKiller, szName, charsmax(szName) );
				copy( szBadge, charsmax(szBadge), g_szBadges[ iBadge ] );
				PokeModExecuteScript( iKiller, "GiveSpecial( %s )", szBadge );
				PokeModExecuteScript( iKiller, "EventPrintAll( %s has earned the %s! )", szName, szBadge );
				PokeModExecuteScript( iKiller, "GiveItem( TM 11 )" );
				PokeModExecuteScript( iKiller, "EventPrint( Misty: Well done. Here is the %s and TM 11. )", szBadge );
				g_iBadgeAttempt[ iKiller ] = BADGE_NONE;
			}
			else
			{
				PokeModExecuteScript( iKiller, "EventPrint( Misty: That kill was from a distance of %d )", floatround( fDist ) );
			}
		}
	}
}




